package org.hamsandwich.example.testMatchers;

import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

/**
 * Without library usage.
 */
public class OldAppleTest {

    @Test
    public void ripensCorrectly() throws Exception {
        //given
        Apple apple = new Apple(Brand.Coxes);

        //when
        apple.ripen();

        //then
        assertThat(apple.brand(), Matchers.allOf(equalTo(Brand.Coxes), not(equalTo(Brand.GoldenDelicious))));
        assertThat(apple.colour(), Matchers.allOf(
                is(not(equalTo(apple.brand().perfectColour))),
                is(equalTo(Brand.GrannySmith.perfectColour)))
        );
    }

    /**
     * Un-ignore this test to show the unclear assertion messages generated by the matcher
     */
    @Test
    @Ignore
    public void ripensCorrectly_willFail() throws Exception {
        //given
        Apple apple = new Apple(Brand.Coxes);

        //when
        apple.ripen();

        //then
        assertThat(apple.brand(), Matchers.allOf(equalTo(Brand.Coxes), not(equalTo(Brand.GoldenDelicious))));
        assertThat(apple.colour(), Matchers.allOf(
                is(equalTo(apple.brand().perfectColour)),       // *will fail as is over-ripe*
                is(equalTo(Brand.GrannySmith.perfectColour)))
        );
    }

}
